/*
 *  Notifier.cpp
 *  AMPlugin
 *
 *  Created by Vu Tiet on 7/9/12.
 *  Copyright 2012 __MyCompanyName__. All rights reserved.
 * 
 *	References: http://svolkov.blogspot.com/2009/01/delegation-pattern-in-c-my-recipe.html
 */

#include "Notifier.h"

Notifier* Notifier::iInstance = NULL;

Notifier::Notifier()
{
    //cout << "In construtor ..." << endl;
	// do nothing
}

Notifier* Notifier::GetInstance()
{
    if ( iInstance == NULL ) {
		iInstance = new Notifier();
    }
	
    return iInstance;
}



void Notifier::NotifyAll(int j) {
	std::vector<IDelegate*>::iterator i = _delegates.begin(), iEnd = _delegates.end();  
	for (; i != iEnd; i++)  
	{  
		//(*i)->Invoke(j++);  
	}  
}

void Notifier::Notify(int j) {
	std::vector<IDelegate*>::iterator i = _delegates.begin(), iEnd = _delegates.end();  
	for (; i != iEnd; i++)  
	{  
		//cout << "notification string: " << (*i)->_notificationStr << endl;
		
		(*i)->Invoke(j);  
	}  
	
}